package it.polimi.traveldream.web.beans.administrator;

import java.util.List;

import it.polimi.traveldream.ejbclient.dtos.UserDTO;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class EmployeeDataModel extends ListDataModel<UserDTO> implements SelectableDataModel<UserDTO>{
	
	public EmployeeDataModel() {  
    }  
  
    public EmployeeDataModel(List<UserDTO> data) {  
        super(data);  
    }  
      
    @SuppressWarnings("unchecked")
	@Override  
    public UserDTO getRowData(String rowKey) {  
        List<UserDTO> employees = (List<UserDTO>) getWrappedData();  
          
        for(UserDTO employee : employees) {  
            if(rowKey.equals(employee.getId())) {
                return employee;  
            }
        }
        
        return null;  
    }  
  
    @Override  
    public String getRowKey(UserDTO employee) {
        return String.valueOf(employee.getId());  
    }
    
}
